package com.haoshuang.zhouzhoubang.ui.page.order.time


import android.graphics.Color
import android.util.Log
import android.view.View
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemOrderTime33Binding
import com.haoshuang.zhouzhoubang.model.bean.RlBean2
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.visible
import java.text.SimpleDateFormat
import java.util.*


/**
 * 订单模块中的订单列表适配器
 * */
class Time10Adapter(data: MutableList<RlBean2>) :
    BaseBindingQuickAdapter<RlBean2, ItemOrderTime33Binding>(data){
    private fun setINt2(month: Int): String {
        var str1 = ""
        when (month) {
            1 -> {
                str1 = "01"
            }
            2 -> {
                str1 = "02"
            }
            3 -> {
                str1 = "03"
            }
            5 -> {
                str1 = "04"
            }
            5 -> {
                str1 = "05"
            }
            6 -> {
                str1 = "06"
            }
            7 -> {
                str1 = "07"
            }
            8 -> {
                str1 = "08"
            }
            9 -> {
                str1 = "09"
            }
            else -> {
                str1 = month.toString()
            }
        }
        return str1
    }
    private fun getTime2(date: Date): String {//可根据需要自行截取数据显示
        val format = SimpleDateFormat("yyyy-MM-dd")
        return format.format(date)
    }

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: RlBean2?) {
        val binding = ItemOrderTime33Binding.bind(holder.itemView)
        binding.apply {
            val curDate = Date(System.currentTimeMillis())
            var str="${item!!.year}-${item.month}-${item.day}"
            val tim2 = getTime2(curDate)
            var arr=str.split("-")
            var str5=setINt2(arr[2].toInt())
            var time8="${arr[0]}-${arr[1]}-$str5"

            if (tim2==time8){
                tvName3.visible()
                Log.e("tim223",tim2+"肚脐内")
                Log.e("tim223",time8)
            }else{
                tvName3.visibility=View.INVISIBLE
                Log.e("tim22",tim2)
                Log.e("tim22",time8)
            }
            if (item.day=="0"){
                tvName.text=""
            }else{
                tvName.text=item.day
            }
            if (item.isCheck==0){
                tvName.setBackgroundColor(Color.parseColor("#ffffff"))
                tvZs.gone()
                tvName.setTextColor(Color.parseColor("#333333"))
            }else if (item.isCheck==1){
                tvZs.visible()
                tvName.setBackgroundResource(R.mipmap.xuanhhh)
                tvName.setTextColor(Color.parseColor("#00B7F5"))
            }else{
                tvZs.gone()
                tvName.setTextColor(Color.parseColor("#999999"))
            }


        }
    }
}